package tsing.kc_work.error;

import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.util.HashSet;
import java.util.Set;

/**
 * @Date 2024/8/8 15:53
 * @Author Tsing
 */
public class Demo {


    public static void main(String[] args) {

        // 定义敏感链接
        Set<String> sensitiveLinks = new HashSet<>();
        sensitiveLinks.add("http://example.com/sensitive1");
        sensitiveLinks.add("http://example.com/sensitive2");
        // 添加其他敏感链接
        String filePath = "path/to/your/file.txt";
        boolean foundSensitiveLink = checkForSensitiveLinks(filePath, sensitiveLinks);

        if (foundSensitiveLink) {
            System.out.println("发现敏感链接！");
        } else {
            System.out.println("没有发现敏感链接。");
        }
    }


    private static boolean checkForSensitiveLinks(String filePath, Set<String> sensitiveLinks) {
        try (BufferedReader br = new BufferedReader(new FileReader(filePath))) {
            String line;
            while ((line = br.readLine()) != null) {
                for (String link : sensitiveLinks) {
                    if (line.contains(link)) {
                        return true; // 找到敏感链接
                    }
                }
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
        return false; // 未找到敏感链接
    }
}


